package demo.springcloud;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.ConfigurableApplicationContext;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author yexi
 */
@SpringBootApplication
@EnableEurekaServer
@Slf4j
public class EurekaServer {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext context = SpringApplication.run(EurekaServer.class, args);
        Integer port = context.getBean(ServerProperties.class).getPort();
        String hostAddress = InetAddress.getLocalHost().getHostAddress();
        log.info("服务已启动，Eureka服务器访问地址：http://{}:{}", hostAddress, port == null ? 8080 : port);
    }
}
